import Vue from 'vue'
import Vuex from 'vuex'
let msgType = require('../utils/msgtype');
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
		msgList:[]
	},
    mutations: {
		pushlist(state,data){
			state.msgList.push(data)
			console.log(state.msgList)
		}
	},
    actions: {
		pushMsg({commit},data){
			console.log('走到pushMsg了')
			console.log(data.type+','+msgType.TEXT)
			if(data.type == msgType.TEXT){
				data.value.forEach((item,index)=>{
					if(item.type == 'emoji'){
						item.data = '/static/images/faces/'+item.data;
					}
				})
			}
			
			  commit('pushlist',data)
		}
	}
})
export default store